<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0	, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<link rel="stylesheet" href="../../css/swiper-3.4.2.min.css">
		<title>测验考试章节页</title>
		<script src="../../script/jquery.min.js" type="text/javascript"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.pingfen  label~
			input {
				float: left;
				width: 25%;
				height: 70%;
				padding: 8px 0px;
				margin-bottom: 0;
				padding-left: 0;
				border: 1px solid #d9d9d9;
			}
			.pingfen  label {
				font-family: 'Helvetica Neue', Helvetica, sans-serif;
				line-height: 1.1;
				vertical-align: middle;
				float: left;
				width: 19%;
				padding: 0.7em 0;
				padding-left: 0.8em;
				padding-right: 0.1em
			}
			.pingfen  span {
				font-family: 'Helvetica Neue', Helvetica, sans-serif;
				line-height: 1.1;
				vertical-align: middle;
				float: left;
				width: 55%;
				padding: 0.7em 0.1em;
			}
			.weui_dialog {
				z-index: 999;
			}
			.swiper-wrapper {
				min-height: 400px
			}
			.Empty_title  .mui-checkbox input[type=checkbox]:checked, .Empty_title .mui-radio input[type=radio]:checked {
				border: 1px solid #333;
				background: 0 0;
			}
			.Empty_title  .mui-checkbox input[type=checkbox]:checked:before, .Empty_title .mui-radio input[type=radio]:checked:before {
				color: #333;
			}
			.stu-test .mui-btn-primary {
				color: #fff;
				background-color: #FF9900;
				border: 1px solid #FF9900;
				padding-left: 2em;
				padding-right: 2em;
			}
			.questionItemImgDiv {
				height: 12em;
				width: 80%;
				max-height: 14em;
				max-width: 95%;
				margin-left: 13px;
			}
			.xuanzeImgDiv {
				width: 80%;
				height: 8em;
				max-height: 10em;
			}
			.tiankong {
				font-family: inherit;
				border-bottom: 1px solid #000;
				margin: 0 8px;
				text-align: center;
				width: auto;
				/*word-break:break-all*/
			}
			.question_video_div {
				padding: 10px 10px;
				padding-left: 20px;
			}
			.question_video_div	video {
				width: 100%;
				height: 13em;
				background-color: black;
			}
			.question_video_div	img {
				width: 100%;
				height: 10em;
				background-color: black;
			}
			.option_video_div {
				padding: 10px 10px;
				padding-left: 55px;
			}
			.option_video_div	img {
				width: 100%;
				height: 8em;
				background-color: black;
			}
			.option_video_div	video {
				width: 100%;
				height: 12em;
			}
			table {
				border: 1px solid #ccc;
				border-collapse: collapse;
				border-spacing: 0;
			}
			td, th {
				border: 1px solid #ccc;
				padding: 0;
				text-align: center
			}
		</style>
	</head>
	<body >
		<div class="stu-test" id="scroll">
			<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
			<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
				<div class="base_navigation_bar base_style_color base_navigation_item_bar">
					<a id="back" class="base_left_item" href="#" onclick="backTestToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
					<span id="title"></span>
					<!--<a class="base_right_item " id="describe"  onclick="openBewrite()" style="display: none;"> 描述</a>-->
				</div>
			</div>
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con-border qusetion-type" >
				<div class="k-con-part" style="position: static">
					<p class="k-text-center k-c323 k-f12">
						<span class="test-score-detail "> 试卷分数：<span class="k-cred" id="score"></span>分 </span>
						<span class="test-score-detail"> 通过分数：<span class="k-cred" id="passscore"></span>分 </span>
						<span class="test-score-detail"> 考试时间：<span class="k-cred" id="kstime"></span>分 </span>
					</p>
				</div>
			</div>
			<div class="k-con test-m-bottom70 test-analysis" id="question_div">
				<div class="swiper-container">
					<div class="swiper-wrapper" ></div>
				</div>
			</div>
			<div class="k-con1 k-text-center k-fixed-bottom test-bottom1" id="sub_div">
				<div class="k-con-part1" id='sub_bt' style="display: none;">
					<div class="remainingtime ">
						<span> 倒计时 </span>
						<span id="kaoShiTime" class="k-cred"></span>
					</div>
					<button type="button" class="mui-btn mui-btn-primary" onclick="CheckSubmit()" >
						交卷
					</button>
					<div class="test_card_div">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
				<div class="k-con-part" id='score_bt' style="display: none;">
					<span class="test-score-detail"> 你的分数：<span class="k-cred" id="your_score" ></span>分 </span>
					<div class="test_card_div" style="top: -10px">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
				<div class="k-con-part1" id='Again_bt' style="display: none;">
					<div class="remainingtime ">
						<span class="test-score-detail"> 你的分数：<span class="k-cred" id="syour_score" ></span>分 </span>
					</div>
					<button type="button" class="mui-btn mui-btn-primary" onclick="AgainTest()" >
						重考
					</button>
					<div class="test_card_div">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
			</div>
			<div id="popover-card" class="mui-popover test-num-card" style=" width: 97%;" >
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll" id="scroll-card"></div>
				</div>
		</div>
		</div>
		<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div class="weui_dialog_alert" id="closeAlert" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum2"></strong>
				</div>
				<div class="weui_dialog_ft">
					<a onclick="Cancel()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div id="LookAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="tilte_look"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="lookno()" href="#" class="weui_btn_dialog default">取消</a>
					<a onclick="lookyes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div id="AgainTestAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="tilte_AgainTest"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="AgainTest_no()" href="#" class="weui_btn_dialog default">取消</a>
					<a onclick="AgainTest_yes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div id="FirstTest_Alert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="tilte_FirstTest"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="FirstTest_no()" href="#" class="weui_btn_dialog default">取消</a>
					<a onclick="FirstTest_yes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/swiper-3.4.2.jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/TestUi.js"></script>
	<script type="text/javascript" src="../../script/attachmentManager.js"></script>
	<script type="text/javascript">
		var daan = new Object();
		var questionLen = '';
		/*题目名称数组*/
		var itemNameArr = new Array();
		/*题目id数组*/
		var itemIdArr = new Array();
		/*题目qid数组*/
		var qidArr = new Array();
		/*点击判断*/
		var clickNum = "";
		/*计划id*/
		var pid = "";
		/*课程id*/
		var cid = "";
		/*章节id*/
		var chapterid = "";
		/*考卷id*/
		var tid = "";
		/*测验开始时间*/
		var stime = "";
		/*考试时间*/
		var timeNum = "";
		/*考试通过成绩*/
		var passScore = "";
		/*是否显示答案*/
		var isanswer = "";
		/*考试次数*/
		var examnum = "";
		/*考试状态*/
		var kstype = '';
		/*考试成绩id*/
		var cjid = "";
		/*考试是否通过*/
		var is_cypass = "";
		/*考试是否参加*/
		var is_cy = '';
		/*考试剩余次数*/
		var test_num = '';
		/*考试开始时间*/
		var statime = '';
		/*考试结束时间*/
		var endtime = '';
		/*0为考试页，1为考试结果页*/
		var html_type = ""//

		var timestamp;
		var is_yuanjuan;
		var apiready = function() {
			preData();
			//开启加载框
			showProgress();
			//获取数据
			judgeTestType();
			// 滚动监听
			listenScroll();
			scrollUI();
			//按钮返回提示
			kebackListen();
		}
		//第一次考试确定按钮
		function FirstTest_yes() {
			$('#FirstTest_Alert').hide();
			if (api.pageParam.hasOwnProperty('isagain') || kstype == 3) {//点击重考进入考试页
				loadTestExamData();
			} else {
				$("#Again_bt").show();
				kstype = 2;
				//未通过状态
				loadExamScoreData(cjid);
			}
		}

		//第一次考试取消按钮
		function FirstTest_no() {
			$('#FirstTest_Alert').hide();
			closeWindow();
		}

		//页面预加载数据
		function preData() {
			var pageParam = api.pageParam;
			var h = api.winHeight * 0.3;
			$('#popover-card').css('height', h);
			var Test_title = $api.getStorage('Test_title');
			$('#title').text(isStringNull(Test_title));
		}

		//发送行为轨迹通知
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.chapterid
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		//判断当前测验章节的状态
		function judgeTestType() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
			};
			cfnetppPOST(url_getChapterType, param, false, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var list = data.data;
						if (list != null && list != '') {
							if (list.hasOwnProperty("is_test")) {
								isanswer = list.isanswer;
								examnum = list.examnum;
								cjid = list.cjid;
								is_cypass = list.is_cypass;
								is_yuanjuan = list.is_yuejuan;
								is_cy = list.is_test;
								test_num = parseInt(examnum - list.num);
								timestamp = list.nowtime;
								statime = parseInt(list.statime);
								endtime = parseInt(list.endtime);
								//								if (api.pageParam.type != 5 && api.pageParam.type != 6) {//不是从消息列表老师已评价的信息挑战过来的
								if (is_yuanjuan != 1) {//未被老师批阅
									if (timestamp - endtime < 0 && timestamp - statime > 0) {//在考试时间内
										if (is_cy == 1) {//已参加考试
											if (is_cypass == 1) {//考试通过
												loadExamScoreData(cjid);
											} else {//考试未通过
												if (examnum == 0) {//无限次
													if (api.pageParam.hasOwnProperty('isagain')) {//点击重考进入考试页
														loadTestExamData();
													} else {
														$("#Again_bt").show();
														kstype = 2;
														//未通过状态
														loadExamScoreData(cjid);
													}
												} else if (examnum > 0) {//多次
													if (test_num > 0) {//多次考试还有考试次数
														//															$('#FirstTest_Alert').show();
														//															$('#tilte_FirstTest').text('考试机会有' + test_num + '次，是否确定进入考试？');
														if (api.pageParam.hasOwnProperty('isagain') || kstype == 3) {//点击重考进入考试页
															loadTestExamData();
														} else {
															$("#Again_bt").show();
															kstype = 2;
															//未通过状态
															loadExamScoreData(cjid);
														}
													} else {//考试次数没了
														kstype = 4;
														//一次考试未通过
														loadExamScoreData(cjid);
													}
												}
											}
										} else {//没参加过
											if (examnum == 0) {//无限次
												loadTestExamData();
											} else if (examnum > 0) {//多次
												if (test_num > 0) {//多次考试还有考试次数
													kstype = 3//初次考试
													$('#FirstTest_Alert').show();
													$('#tilte_FirstTest').text('考试机会有' + test_num + '次，是否确定进入考试？');
												}
											}
										}
									} else if (timestamp - endtime > 0 && timestamp - statime > 0) {//考试时间过期
										if (is_cy == 1) {//参加过考试
											kstype = 5;
											//参加过考试，但考试过期
											loadExamScoreData(cjid);
										} else {//没参加考试
											back('测验已过期，无法进入');
										}
									} else if (timestamp - statime < 0) {//考试时间未开始
										back('测验未开始,无法进入,测验时间<br>' + getCurrentDate(isStringNull(list.statime)) + "至" + getCurrentDate(isStringNull(list.endtime)));
									} else {
										back('数据异常');
									}
								} else {//已被老师批阅
									if (timestamp - endtime < 0 && timestamp - statime > 0) {//在考试时间内
										if (is_cy == 1) {//已参加考试
											if (is_cypass == 1) {//考试通过
												loadExamScoreData(cjid);
											} else {//考试未通过
												if (examnum == 0) {//无限次
													//
													if (api.pageParam.hasOwnProperty('isagain')) {//点击重考进入考试页
														loadTestExamData();
													} else {
														$("#Again_bt").show();
														kstype = 2;
														//未通过状态
														loadExamScoreData(cjid);
													}
												} else if (examnum > 0) {//多次
													if (test_num > 0) {//多次考试还有考试次数
														//															$('#FirstTest_Alert').show();
														//															$('#tilte_FirstTest').text('考试机会有' + test_num + '次，是否确定进入考试？');
														if (api.pageParam.hasOwnProperty('isagain') || kstype == 3) {//点击重考进入考试页
															loadTestExamData();
														} else {
															$("#Again_bt").show();
															kstype = 2;
															//未通过状态
															loadExamScoreData(cjid);
														}
													} else {//考试次数没了
														kstype=4;
														loadExamScoreData(cjid);
													}
												}
											}
										} else {//没参加过
											if (examnum == 0) {//无限次
												loadTestExamData();
											} else if (examnum > 0) {//多次
												if (test_num > 0) {//多次考试还有考试次数
													$('#FirstTest_Alert').show();
													$('#tilte_FirstTest').text('考试机会有' + test_num + '次，是否确定进入考试？');
												}
											}
										}
									} else if (timestamp - endtime > 0 && timestamp - statime > 0) {//考试时间过期
										if (is_cy == 1) {//参加过考试
											loadExamScoreData(cjid);
										} else {//没参加考试
											back('测验已过期，无法进入');
										}
									} else if (timestamp - statime < 0) {//考试时间未开始
										back('测验未开始,无法进入,测验时间<br>' + getCurrentDate(isStringNull(list.statime)) + "至" + getCurrentDate(isStringNull(list.endtime)));
									} else {
										back('数据异常');
									}
								}
							} else {
								back('数据异常');
							}
						} else {
							back('当前章节数据为空');
						}
					} else if (data.code == 128) {
						back('当前章节数据为空');
						clickNum = 3;
					} else {
						back('数据异常');
						clickNum = 3;
					}
				} else {
					api.toast({
						msg : '网络异常',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		function daojishi() {
			var t = setInterval(function() {
				if (timeNum > 0) {
					timeNum--;
					var currentTime = sZhuanHms(timeNum);
					x = document.getElementById("kaoShiTime");
					//查找元素
					x.innerHTML = currentTime;
				} else {
					clearTimeout(t);
					api.toast({
						msg : '答题时间已到正在为您交卷'
					});
					DeleteAnswerNullData();
					SubmitData();
				}
			}, 1000);
		}

		//考试结果接口
		function loadExamScoreData(cjid) {
			var params = {
				cuid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
				tid : api.pageParam.rid,
				cjid : cjid,
			};
			cfnetppPOST(url_getTestScoreList, params, true, function(data, status) {
				api.hideProgress();
				if (status == 'success') {
					if (data.status == 1) {
						var jsonData = data.data;
						var classDatas = JSON.parse(jsonData.timudetail);
						if (classDatas != null && classDatas != '') {
							html_type = 1;
							if (api.pageParam.type == 0) {//mocc
								sendBuriedNotifi('0', 'mooc课程测验章节结果页', '013');
							} else {
								sendBuriedNotifi('0', '自由课程测验章节结果页', '055');
							}
							if (is_cypass == 1 || kstype == 4 || kstype == 5) {//考试成绩通过和一次考试机会未通过，已参加考试，但试卷过期
								$('#score_bt').show();
							}
							$('#sub_bt').hide();
							$('#syour_score').text(parseFloat(jsonData.score).toFixed(1));
							$('#passscore').text(jsonData.passscore);
							$('#kstime').text(jsonData.elapse);
							$('#your_score').text(parseFloat(numNull(jsonData.score)).toFixed(1));
							$('#score').text(jsonData.testscore);
							var examList = GetHtmlTestArrayList(classDatas);
							if (examList != '') {
								SetExamScoreUI(examList);
							} else {
								back('测验结果题目为空');
								clickNum = 3;
							}
						} else {
							back('题目为空');
						}
					} else {
						api.toast({
							msg : '网络异常,获取题目失败',
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '网络异常,获取题目失败',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		//考试题目接口
		function loadTestExamData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
				tid : api.pageParam.rid,
				type : 0//学生身份
			};
			cfnetppPOST(url_getTest, param, false, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var list = data.json;
						if (list != null) {
							html_type = 0;
							if (api.pageParam.type == 0) {//mocc
								sendBuriedNotifi('0', 'mooc课程测验章节页', '012');
							} else {
								sendBuriedNotifi('0', '自由课程测验章节页', '054');
							}
							$('#score').text(list.score);
							$('#passscore').text(list.passscore);
							$('#kstime').text(list.elapse);
							timeNum = parseInt(list.elapse) * 60;
							if (api.pageParam.is_teacher != 1) {
								$('#sub_bt').show();
								$('#score_bt').hide();
							}
							tid = list.id;
							stime = list.stime;
							passScore = parseInt(list.passscore);
							var examlist = list.examlist;
							if (examlist != null && examlist != '') {
								questionLen = examlist.length;
								setUpObject(examlist);
								$(".swiper-wrapper").append(SetTestExamUI(examlist));
								kstype = 1;
								InitmySwiper();
								//计时器
								daojishi();
							} else {
								back('考试题目为空');
								clickNum = 3;
							}
						} else {
							back('考试题目为空');
							clickNum = 3;
						}
					} else if (data.code == 116) {
						back('考试次数达到上限');
						clickNum = 3;
					} else if (data.code == 111) {
						back('测验已过期');
						clickNum = 3;
					} else if (data.code == 110) {
						back('测验未开始');
						clickNum = 3;
					} else {
						back('数据异常');
						clickNum = 3;
					}
				} else {
					api.toast({
						msg : '网络异常',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		// 滚动监听
		function listenScroll() {
			var winHeight = $(window).height();
			//获取当前页面高度
			$(window).resize(function() {
				var thisHeight = $(this).height();
				if (winHeight - thisHeight > 50) {
					//当软键盘弹出，在这里面操作
					$("#sub_div").css('display', 'none');
				} else {
					$("#sub_div").css('display', 'block');
					//当软键盘收起，在此处操作
				}
			});
		}

		function setUpObject(data) {
			var questions = data;
			for (var i = 0; i < questions.length; i++) {
				var question = questions[i];
				qidArr.push(question.qid);
				//子问题数组
				//子问题数组
				if (question.qtype == '1' || question.qtype == '3' || question.qtype == '8' || question.qtype == '5' || question.qtype == '11') {//单选题
					//取出子题目
					daan[question.qid] = new String();
				} else if (question.qtype == '2' || question.qtype == '7' || question.qtype == '9') {//多选题识图题
					//取出子题目
					daan[question.qid] = new Array();
				} else if (question.qtype == '4' || question.qtype == '10') {//论述题
					//取出子题目
					daan[question.qid] = new Array();
				}
			}
		}

		//删除未回答的题目数组
		function DeleteAnswerNullData() {
			for (var k = 0; k < qidArr.length; k++) {
				if ( typeof daan[qidArr[k]] == 'string') {
					if (daan[qidArr[k]] == null || daan[qidArr[k]] == "" || daan[qidArr[k]] == undefined) {
						delete daan[qidArr[k]];
					}
				} else if ( typeof daan[qidArr[k]] == 'object') {
					if ( typeof daan[qidArr[k]].length == 'number') {
						if (daan[qidArr[k]].length == 0) {
							delete daan[qidArr[k]];
						}
					}
				}
			}
		}

		//考试结果页html拼接
		function SetExamScoreUI(list) {
			var qxuan = '';
			var data = list;
			var OrderNumStr = ''
			questionLen = data.length;
			var qdaanStr = '';
			var xuanzeStr = "";
			var questionStr = "";
			var scoreStr = "";
			//	生成答题卡题号
			TestScorePopoverCardNum(questionLen);
			for (var i = 0; i < questionLen; i++) {
				if (data[i] != null && data[i] != '') {
					qxuan = qxuanxiangIsNull(data[i].qxuanxiang);
					scoreStr = (i + 1) + '/' + questionLen + "." + "(" + judgeQuestionScore(data[i]) + "分)";
					questionStr = data[i].qtype != 11 ? questionsImgIsNull(data[i].questions) : FillInBlankQuestionStr(data[i]);
					$(".swiper-wrapper").append('<div class="swiper-slide" id="item' + (i + 1) + '" itemtype="' + data[i].qtype + '"></div>')
					if (data[i].qtype == 1 || data[i].qtype == 3 || data[i].qtype == 8) {
						//	是单选或判断
						qdaanStr = dtjieguoIsNull(data[i].dtjieguo, data[i].qdaan, isanswer, is_cypass, i)
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + qdaanStr + '<div class="test-answer-list left_10" >' + '</div>' + '</div>')
						var qxuanLen = data[i].qtype != 3 ? qxuan.length : 2;
						for (var k = 0; k < qxuanLen; k++) {
							var xuanzeStr1 = data[i].qtype != 3 ? qxuan[k].xuanzhe : panxuanzeReturnStr(k);
							xuanzeStr = xuanzheImgIsNull(xuanzeStr1);
							if (data[i].dtjieguo != "" && data[i].dtjieguo != null) {
								if ((k + 1 ) != charCodeAt(data[i].dtjieguo)) {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-radio mui-left " >' + xuanzeStr + '<input dataindex="' + (k + 1) + '"  onclick="return false;"    name="radio' + data[i].qid + '" type="radio"   itemid="' + data[i].qid + '">' + '</div> ')
								} else {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-radio mui-left " >' + xuanzeStr + '<input dataindex="' + (k + 1) + '"  checked="checked"  onclick="return false;"   name="radio' + data[i].qid + '" type="radio"   itemid="' + data[i].qid + '" >' + '</div> ')
								}
							} else {
								$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-radio mui-left Empty_title" >' + xuanzeStr + '<input dataindex="' + (k + 1) + '"    onclick="return false;"   name="radio' + data[i].qid + '" type="radio"   itemid="' + data[i].qid + '"   >' + '</div> ')
							}
						}
					} else if (data[i].qtype == 2 || data[i].qtype == 9) {//多选题
						if (data[i].qdaan != null) {
							var keys1 = [];
							keys1 = getCjjieguoKey(data[i].dtjieguo);
							qdaanArr = strIsNullSpite(data[i].qdaan);
							var userchooseLetter = [];
							for (var j = 0; j < keys1.length; j++) {
								userchooseLetter.push(charCodeAt(keys1[j]))
							}
							qdaanStr = dtjieguoIsNull(keys1, qdaanArr, isanswer, is_cypass, i);
							$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + qdaanStr + '<div class="test-answer-list left_10" >' + '</div>' + '</div>')
							//	是多选
							for (var k = 0; k < qxuan.length; k++) {
								xuanzeStr = xuanzheImgIsNull(qxuan[k].xuanzhe);
								if (userchooseLetter.toString().indexOf(k + 1) == -1) {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + xuanzeStr + '<input dataindex="' + (k + 1) + '" name="checkbox1"  onclick="return false;"    value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								} else {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + xuanzeStr + '<input dataindex="' + (k + 1) + '"  checked="checked"   onclick="return false;"  name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								}
							}
						} else {
							$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + '<p class="k-cred">' + "无正确答案" + '</p>' + '<div class="test-answer-list left_10" >' + '</div>' + '</div>')
							for (var k = 0; k < qxuan.length; k++) {
								xuanzeStr = xuanzheImgIsNull(qxuan[k].xuanzhe);
								if (userchooseLetter.toString().indexOf(k + 1) == -1) {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + xuanzeStr + '<input dataindex="' + (k + 1) + '" name="checkbox1"  onclick="return false;"    value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								} else {
									$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + xuanzeStr + '<input dataindex="' + (k + 1) + '"  checked="checked"   onclick="return false;"  name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">' + '</div>')
								}
							}
						}
					} else if (data[i].qtype == 7) {//识图题
						qdaanArr = strIsNullSpite(data[i].qdaan);
						var keys1 = [];
						keys1 = getCjjieguoKey(data[i].dtjieguo);
						var userchooseLetter = [];
						for (var j = 0; j < keys1.length; j++) {
							userchooseLetter.push(charCodeAt(keys1[j]))
						}
						qdaanStr = dtjieguoIsNull(keys1, qdaanArr, isanswer, is_cypass, i)
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + qdaanStr + '<div class="test-answer-list left_10" >' + '</div>' + '</div>')
						for (var k = 0; k < qxuan.length; k++) {
							var inputStr = "";
							xuanzeStr = xuanzheImgIsNull(qxuan[k].xuanzhe)
							if (userchooseLetter.toString().indexOf(k + 1) == -1) {
								inputStr = '<input dataindex="' + (k + 1) + '" name="checkbox1"  onclick="return false;"    value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">'
							} else {
								inputStr = '<input dataindex="' + (k + 1) + '"  checked="checked"   onclick="return false;"  name="checkbox1" value="Item 1" type="checkbox"  itemid="' + data[i].qid + '">'
							}
							$("#item" + (i + 1) + " .test-answer-list").append('<div class="mui-input-row mui-checkbox mui-left" >' + xuanzeStr + inputStr + '</div>')
						}
					} else if (data[i].qtype == 4 || data[i].qtype == 10) {//论述题和案例分析题
						var pingfenStr = '';
						qdaanStr = dtjieguoIsNull(data[i].dtjieguo, data[i].qjiexi, isanswer, is_cypass, i)
						if (data[i].pingfen != null && data[i].pingfen != '') {//已被老师评分
							pingfenStr = '<div class="mui-input-row pingfen"style="margin-top: 23px">' + '<label>评分:' + '</label>' + ' <span style="color: red">' + data[i].pingfen + '分' + '</span>' + '</div>'
						} else {
							pingfenStr = '<div class="mui-input-row pingfen"style="margin-top: 23px">' + '<label>评分:' + '</label>' + ' <span style="color: red">' + '请耐心等待老师批改' + '</span>' + '</div>'
						}
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + qdaanStr + '<div class="test-answer-list left_10" >' + '</div>' + '</div>' + pingfenStr)
						// 论述
						$("#item" + (i + 1) + " .test-answer-list").append('<div class="test-answer-list">' + '<textarea  class="k-texttarea k-f14" disabled="disabled"    id="content" itemid="' + data[i].qid + '">' + isStringNull(data[i].dtjieguo) + '</textarea>' + '</div>')
					} else if (data[i].qtype == 5) {//上传题
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5 word-break">' + scoreStr + questionStr + '<p class="k-cred left_10">' + "移动端暂不支持上传题，请在PC端查看！" + '</p>' + '</p>' + '<div class="test-answer-list left_10"  onclick="GetAnswerData(' + i + ')"  onclick="return false;" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
						//					} else if (data[i].qtype == 9) {//视频题
						//						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5 ">' + scoreStr + questionStr + '<p class="k-cred left_10">' + "移动端暂不支持视频题，请在PC端查看！" + '</p>' + '</p>' + '<div class="test-answer-list left_10"  onclick="return false;" itemtype="' + data[i].qtype + '">' + '</div>' + '</div>')
					} else if (data[i].qtype == 11) {
						var user_answer = data[i].user_answer.split('|');
						qdaanStr = dtjieguoIsNull(data[i].dtjieguo, data[i].qjiexi, isanswer, is_cypass, i)
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + ByIdGetQuestionTypeName(data[i].qtype) + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + questionStr + '</p>' + qdaanStr + '<div class="test-answer-list left_10" >' + '</div>' + '</div>');
						$.each(user_answer, function(k, e) {
							$("#item" + (i + 1)).find('.tiankong:eq(' + k + ')').attr("value", e)
							$("#item" + (i + 1)).find('.tiankong:eq(' + k + ')').attr("readonly", "readonly");
						});
					}
				} else {
					$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-normal');
					//					itemNameArr.push('空题');
					//设置初始题目标题
					$(".swiper-wrapper").append('<div class="swiper-slide" id="item' + (i + 1) + '" ></div>')
					$("#item" + (i + 1)).append('<div class="k-con-part clearfix tont" >' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + '本题为空' + '</p>' + '<div  class="test-answer-list"      onclick="GetAnswerData(' + i + ')" >' + '</div>' + '</div>')
				}
			}
			var mySwiper = new Swiper('.swiper-container', {
				autoHeight : true,
				autoplayDisableOnInteraction : false,
				direction : 'horizontal',
				loop : false,
			})
			// 点击答题卡切换
			$("#popover-card span").on("click", function() {
				var index = $(this).index();
				mySwiper.slideTo(index, 1000, false);
				mui('#popover-card').popover('hide')
			});
		}

		//判断答案是否正确和相应答题卡显示
		function dtjieguoIsNull(dtjieguo, qdaan, isanswer, is_cypass, i) {
			var dtjieguoStr = isStringNotNull(dtjieguo);
			var qdaanStr = isStringNotNull(qdaan);
			if (isanswer == 1 && is_cypass == 1) {//显示正确答案,并且通过
				if (dtjieguoStr == "" || dtjieguoStr == null || dtjieguoStr == "null") {
					$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-false');
					return '<p class="k-cred">' + "未提交,正确答案:" + qdaan + '</p>'
				} else {
					if (dtjieguoStr == qdaanStr) {//答案正确
						$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-true');
						return '<p class="k-cred">' + "正确答案:" + qdaan + '</p>'
					} else {
						$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-false');
						return '<p class="k-cred">' + "回答错误,正确答案:" + qdaan + '</p>'
					}
				}
			} else {
				if (dtjieguoStr == "" || dtjieguoStr == null || dtjieguoStr == "null") {
					$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-false');
					return '<p class="k-cred">' + "未提交" + '</p>';
				} else {
					if (dtjieguoStr == qdaanStr) {//答案正确
						$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-true');
						return '<p class="k-cred">' + "回答正确" + '</p>'
					} else {
						$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-false');
						return '<p class="k-cred">' + "回答错误" + '</p>';
					}
				}
			}
		}

		//判断当前字段是否为空
		function isStringNotNull(str) {
			if (isEmpty(str)) {
				return "";
			} else {
				return str.toString();
			}
		}

		//检查题目是否提交
		function CheckSubmit() {
			DeleteAnswerNullData();
			var daanLen = ObjectCount(daan);
			var strLen = questionLen - daanLen;
			if (strLen > 0) {//剩余题目数量大于0
				$("#checkNum").text("您还有" + strLen + "道题未填写,是否确定填写?");
			} else {
				$("#checkNum").text("是否确定提交？");
			}
			$('#offlineAlert').show();
			clickNum = 1;
		}

		//系统返回键监听事件
		function kebackListen() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				//coding...
				backTestToast();
			});
		}

		//退出考试提示
		function backTestToast() {
			if(clickNum !=3 && clickNum!=5 && kstype==1){
				api.toast({
					msg : '考试期间不允许退出',
					duration : 2000,
					location : 'bottom'
				});
			}else
				closeWindow();
			// if (clickNum == 3) {
			// } else if (clickNum == 5) {//查看考试结果页
			// 	closeWindow();
			// } else {//参加考试页
			// 	if(kstype!=1)
			//
				// if (kstype == 1) {//题目加载完,进入考试页
				// 	$("#checkNum").text("是否退出测验?一旦退出计作一次考试");
				// 	$('#offlineAlert').show();
				// 	clickNum = 2;
				// } else {//考试加载异常
				// 	$("#checkNum").text("是否退出测验?");
				// 	$('#offlineAlert').show();
				// 	clickNum = 2;
				// }
			// }
		}

		//退出考试提示
		function back(str) {
			$('#sub_bt').hide();
			$("#checkNum2").html(str);
			$('#closeAlert').show();
		}

		//是否退出考试按钮
		function Cancel() {
			$('#closeAlert').hide();
			closeWindow();
		}

		//是否退出出考试取消按钮
		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//是否退出页面确定按钮
		function cleanConfirm() {
			$('#offlineAlert').hide();
			if (clickNum == 1) {
				showProgress();
				DeleteAnswerNullData();
				SubmitData();
			} else if (clickNum == 2) {
				if (kstype == 1) {
					showProgress();
					daan = "{}";
					clickNum = 10;
					SubmitData();
				} else {
					closeWindow();
				}
			} else if (clickNum == 5) {
				closeWindow();
			}
		}

		//关闭到章节列表页
		function closeWindow() {
			if (html_type == 0) {
				if (api.pageParam.type == 0) {//mocc
					sendBuriedNotifi('1', 'mooc课程测验章节页', '012');
				} else if (api.pageParam.type == 1) {
					sendBuriedNotifi('1', '自由课程测验章节页', '054');
				}
			} else {
				if (api.pageParam.type == 0) {//mocc
					sendBuriedNotifi('0', 'mooc课程测验章节结果页', '013');
				} else {
					sendBuriedNotifi('0', '自由课程测验章节结果页', '055');
				}
			}
			if (api.pageParam.hasOwnProperty('type')) {
				if (api.pageParam.type == 1) {//自由课程章节列表跳转过来
					if (api.pageParam.hasOwnProperty('openType') && api.pageParam.openType == "train_stu") {//实习学习跳转而来
						api.closeToWin({
							name : 'Student_trainFreeCourseTab'
						});
					} else {//教学学习跳转而来
						api.closeToWin({
							name : 'Student_FreeCourseTab'
						});
					}
				} else {//mocc章节列表跳转过来
					api.closeWin({
					});
				}
			} else {//消息列表挑转过来
				api.closeWin({
				});
			}
		}

		//提交答题数据
		function SubmitData() {
			var param = {
				tid : api.pageParam.rid, //测验id
				pid : api.pageParam.pid, //计划id
				cid : api.pageParam.cid, //课程id
				vid : api.pageParam.id, //章节id
				uid : $api.getStorage('cfnetppuid'), //用户id
				jid : $api.getStorage('cfnetppjxid'), //集团id
				stime : timestamp, //开始答测验时间（时间戳)
				answer : daan
			};
			cfnetppPOST(url_subtest, param, false, function(data, status) {
				hideProgress();
				if (api.pageParam.type == 0) {//mocc
					SendBusinessOperationsLogNotifi('Mocc测验页', '012', param, param, '', data, 'Mocc课程提交测验接口', '012-01')
				} else {
					SendBusinessOperationsLogNotifi('自由课程测验页', '054', param, param, '', data, '自由课程提交测验接口', '054-01')
				}
				if (status == 'success') {
					if (data.code == 200) {
						if (clickNum != 10) {
							ShowToast('提交成功');
							sendNotifi();
							var score = parseInt(data.json.score);
							if (score >= passScore) {//考试通过
								$('#LookAlert').show();
								$("#tilte_look").text("当前得分" + score + "分，恭喜您已通过考试！是否查看详情？");
							} else if (score < passScore) {//考试未通过
								if (data.json.num == -1) {//考试未通过但考试次数已到上限
									back('您的成绩暂未通过,考试次数已达到上限');
								} else {//考试未通过但考试次数未达到上限
									if (examnum == 0) {//考试次数无限次
										$('#AgainTestAlert').show();
										$("#tilte_AgainTest").text("当前得分" + score + "分,很遗憾未通过考试,是否重考？");
									} else {
										$('#AgainTestAlert').show();
										$("#tilte_AgainTest").text("当前得分" + score + "分,很遗憾未通过考试，您还有" + data.json.num + "次考试机会,是否重考？");
									}
								}
							}
						} else {
							closeWindow();
						}
					} else {
						api.toast({
							msg : data.message,
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '提交失败',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		//重考
		function AgainTest() {
			$('#AgainTestAlert').show();
			if (examnum == 0) {//无限次
				$("#tilte_AgainTest").text("无限次是否重考？");
			} else {
				if (test_num > 0) {
					$("#tilte_AgainTest").text("您还有" + test_num + "次考试机会,是否重考？");
				}
			}
		}

		//重考弹窗取消按钮
		function AgainTest_no() {
			$('#AgainTestAlert').hide();
			closeWindow();
		}

		//重考弹窗确定按钮
		function AgainTest_yes() {
			$('#AgainTestAlert').hide();
			var y = 0;
			var h = api.winHeight - y;
			api.openWin({useWKWebView:true,
				name : 'New_student_study_freecourse_TestExam',
				url : 'New_student_study_freecourse_TestExam.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h,
				},
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					id : api.pageParam.id,
					rid : api.pageParam.rid,
					type : api.pageParam.type,
					isagain : '1',
					openType : api.pageParam.openType
				},
				reload : true
			});
		}

		//是否查看考试结果弹窗确定按钮
		function lookyes() {
			$('#LookAlert').hide();
			openTestScore();
		}

		//是否查看考试结果弹窗取消按钮
		function lookno() {
			$('#LookAlert').hide();
			closeWindow()
		}

		function sendNotifi() {
			//			api.sendEvent({
			//				name : 'RefreshTestNotifi'
			//			});
			api.sendEvent({
				name : 'freeCourseRecordNotifi',
				extra : {
					uid : $api.getStorage('cfnetppuid'),
					jid : $api.getStorage('cfnetppjxid'),
					cid : api.pageParam.cid,
					vid : api.pageParam.id, //章节id
					pid : api.pageParam.pid,
				}
			});
		}

		//		//打开测验结果页
		function openTestScore() {
			var y = 0;
			var h = api.winHeight - y;
			api.openWin({useWKWebView:true,
				name : 'New_student_study_freecourse_TestExam',
				url : 'New_student_study_freecourse_TestExam.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h,
				},
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					id : api.pageParam.id,
					rid : api.pageParam.rid,
					type : api.pageParam.type,
					openType : api.pageParam.openType
				},
				reload : true
			});
		}
	</script>
</html>